package com.company.example.copy;

import java.io.Serializable;

/**
 * Created by ywl on 2017/2/23.
 */
public final class Person implements Cloneable,Serializable{
    private String name;
    private int age;
    private User user;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
        user = new User();
        user.setName(name);
        user.setAge(age);
    }

    public Person() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String toString(){
        return this.name + "-->" + this.age+"--pp:"+ this.user.getAge();
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Object clone(){
        Person o =null;
        try {
            o = (Person)super.clone();
            o.user = (User) this.user.clone();
        }catch(Exception e){
            e.printStackTrace();
        }
        return o;
    }
}
